package testpackage.java.al.json.gson;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.common.entity.Man;
import com.java.al.json.gson.GsonControlJson;

public class TGSON {
	GsonControlJson gsonControlJson;
	@Before
	public void before(){
		gsonControlJson = GsonControlJson.getInstance();
	}
	
	@Test
	public void TEntityChangeToJSON(){
		Man man = new Man();
		man.setAge("18");
		man.setHasBomb(true);
		man.setName("元始天王");
		gsonControlJson.entityChangeToJSON(man);
	}
	
	@Test
	public void TJSONToEntity(){
		String json = "{'hasBomb':true,'isStrong':false,'name':'元始天王','age':'18'}";
		Man man = new Man();
		man = gsonControlJson.JSONToentityChange(json, man);
		System.out.println(man.getName());
		System.out.println(man.isHasBomb());
	}
	@After
	public void end(){
		gsonControlJson = null;
	}
}
